<?php

require_once 'Base.php';

class BindAppID extends Base {
    public function send(){
        if($_POST){
            $requestParams=$_POST;
            $requestParams['sign']=$this->generateSign($requestParams,'MD5');
            $url="https://api.mch.weixin.qq.com/secapi/mch/addsubdevconfig";

            $response=$this->curlRequest($url,$this->arrayToXml($requestParams),[],true);

            if($response['return_code'] != 'SUCCESS'){
                exit($response['return_msg']);
            }
            if($response['result_code'] != 'SUCCESS'){
                exit($response['err_code_des']);
            }
            $this->checkSign($response);

            //将结果进行储存
            file_put_contents($this->bindAppIDPath,json_encode($response),FILE_APPEND);
            return '绑定APPID结果：'.$response['result_code'];
        }
    }
}

echo (new BindAppID())->send();